package com.heima.admin.controller.v1;

import com.heima.admin.service.AdSensitiveService;
import com.heima.model.admin.dtos.SensitiveDTO;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
@Api(value = "敏感词管理", tags = "敏感词管理API")
public class AdSensitiveController {

    @Autowired
    private AdSensitiveService adSensitiveService;

    // 查询敏感词
    @ApiOperation("查询敏感词")
    @PostMapping("/list")
    public ResponseResult addSensitive(@RequestBody SensitiveDTO sensitiveDTO){
        return adSensitiveService.findSensitive(sensitiveDTO);
    }

    // 添加敏感词
    @ApiOperation("添加敏感词")
    @PostMapping("/save")
    public ResponseResult addSensitive(@RequestBody AdSensitive adSensitive){
        return adSensitiveService.addSensitive(adSensitive);
    }

    // 修改敏感词
    @ApiOperation("修改敏感词")
    @PostMapping("/update")
    public ResponseResult updateSensitive(@RequestBody AdSensitive adSensitive){
        return adSensitiveService.updateSensitive(adSensitive);
    }

    // 删除敏感词
    @ApiOperation("删除敏感词")
    @DeleteMapping("/del/{id}")
    public ResponseResult deleteSensitive(@PathVariable("id") Integer id){
        return adSensitiveService.deleteSensitive(id);
    }
}
